package com.sctvcloud.bazhong.ui.manager;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class MessageManager {

    private static final long se = 5 * 60 * 1000;//循环获取的时间间隔
    private Context context;
    private DownLoadImage downLoadImage;
    private ArrayList<Object> adImgs;
    private List<String> localFiles = new ArrayList<>();
    private int time;
    private int msgKey;
    private Timer readyTimer;

    public MessageManager(Context context) {
        this.context = context;
    }

    /**
     * 启动消息定时更新服务
     */
    public void startMessageService(final Handler mHandler, int key) {
        try {
            msgKey = key;
            readyTimer = new Timer(true);
            Date d1 = new Date();
            readyTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    Message msg = new Message();
                    msg.what = msgKey;
                    mHandler.sendMessage(msg);
                }
            }, d1, se);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
